package com.hw.shortlink.project.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.hw.shortlink.project.dao.entity.ShortLink;
import com.hw.shortlink.project.dto.req.ShortLinkCreateBatchReqDto;
import com.hw.shortlink.project.dto.req.ShortLinkCreateReqDto;
import com.hw.shortlink.project.dto.req.ShortLinkPageReqDto;
import com.hw.shortlink.project.dto.req.ShortLinkUpdateReqDto;
import com.hw.shortlink.project.dto.resp.ShortLinkCreateBatchRespDto;
import com.hw.shortlink.project.dto.resp.ShortLinkCreateRespDto;
import com.hw.shortlink.project.dto.resp.ShortLinkGroupCountQueryRespDto;
import com.hw.shortlink.project.dto.resp.ShortLinkPageRespDto;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.util.List;

public interface ShortLinkService extends IService<ShortLink> {

    /**
     * 新增短链接
     * @param shortLinkCreateReqDTO
     * @return
     */
    ShortLinkCreateRespDto createShortLink(ShortLinkCreateReqDto shortLinkCreateReqDTO);

    /**
     * 批量新增短链接
     * @param shortLinkCreateBatchReqDto
     * @return
     */
    ShortLinkCreateBatchRespDto createShortLinkBatch(ShortLinkCreateBatchReqDto shortLinkCreateBatchReqDto);

    /**
     * 修改短链接
     * @param shortLinkUpdateReqDTO
     */
    void updateShortLink(ShortLinkUpdateReqDto shortLinkUpdateReqDTO);

    /**
     * 分页查询
     * @param shortLinkPageReqDto
     * @return
     */
    IPage<ShortLinkPageRespDto> pageQuery(ShortLinkPageReqDto shortLinkPageReqDto);

    /**
     * 查询分组内的短链接数量
     * @param gids
     * @return
     */
    List<ShortLinkGroupCountQueryRespDto> listGroupShortLinkCount(List<String> gids);

    /**
     * 短链接跳转到原始链接
     * @param shortUri
     * @param request
     * @param response
     */
    void redirectUrl(String shortUri, HttpServletRequest request, HttpServletResponse response);

    /**
     * 短链接监控数据统计
     * @param request
     * @param response
     * @param fullShortUrl
     * @param gid
     */
    void shortLinkStats(HttpServletRequest request, HttpServletResponse response, String fullShortUrl);


}
